package com.lz.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 微信认证接口
 * Created by lz on 2018/8/24.
 */
@RestController
@RequestMapping("/wechat")
@Slf4j
public class WeixinController {

    @GetMapping("/auth")
    public void auth(@RequestParam("code")String code){
        log.info("进入微信验证");
        System.out.println(code);
        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx156906c3975e737e&secret=073ccc1fa95b15db4756fce5daf97540&code=" + code + "&grant_type=authorization_code";

        RestTemplate restTemplate = new RestTemplate();
        String forObject = restTemplate.getForObject(url, String.class);
        log.info(forObject);
    }
}
